#include "QCreerGraphe.h"

#include"MainWindow.h"


QCreerGraphe::QCreerGraphe(MainWindow *parent):QDialog(parent){
    mainWin = parent;

    ok = new QPushButton("Valider");
    annuler = new QPushButton("Annuler");
    lDelta = new QLabel("delta max: ");
    lNbSommet = new QLabel("Nombre Sommet:");
    radio = new QRadioButton("generer un graphe complet");
    cDelta = new QSpinBox();
    cDelta->setMinimum(1);
    cDelta->setMaximum(100000);


    cNbSommet = new QSpinBox();
    cNbSommet->setMinimum(2);
    cNbSommet->setMaximum(99999);
    this->setFixedSize(250,200);
    bVLayout = new QVBoxLayout();

    bHLayout = new QHBoxLayout();
    bHLayout->addWidget(lDelta);
    bHLayout->addWidget(cDelta);
    bVLayout->addLayout(bHLayout);

    bHLayout = new QHBoxLayout();
    bHLayout->addWidget(lNbSommet);
    bHLayout->addWidget(cNbSommet);
    bVLayout->addLayout(bHLayout);
    bVLayout->addWidget(radio);
    bHLayout = new QHBoxLayout();
    bHLayout->addWidget(ok,Qt::AlignBottom);
    bHLayout->addWidget(annuler,Qt::AlignBottom);
    bVLayout->addLayout(bHLayout);

    
    connect(ok, SIGNAL(clicked()),this,SLOT(valider()));
    connect(radio,SIGNAL(clicked()),this,SLOT(fonction_radio()));


    this->setLayout(bVLayout);
    this->show();

    this->setDisabled(false);
}



QCreerGraphe::~QCreerGraphe(){}

void QCreerGraphe::valider(){
    int mode = 0;
    int delta = cDelta->value();
    cou<<"salut"<<endl;
    int nbSommet = cNbSommet->value();
    if (radio->isChecked()) mode = 1;
    mainWin->getGrapheScene()->nouveau(nbSommet,delta,mode);


}

void QCreerGraphe::fonction_radio(){
    cDelta->setEnabled(!cDelta->isEnabled());

}
